package com.sky.mapper;

import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ShopCartMapper {
    /**
     * 查看购物车
     *
     * @param userId
     * @return
     */
    @Select("select * from shopping_cart where user_id=#{userId}")
    List<ShoppingCart> findShopCart(Long userId);

    /**
     * 添加购物车
     */
    void addShopCart(ShoppingCart shoppingCart);

    /**
     * 动态条件查询
     *
     * @param shopCart
     * @return
     */
    List<ShoppingCart> list(ShoppingCart shopCart);

    /**
     * 动态条件修改
     *
     * @param shopCart
     */
    void updateShopCart(ShoppingCart shopCart);

    /**
     * 删除购物车中一个商品
     * @param shoppingCart
     */
    void deleteById(ShoppingCart shoppingCart);

    /**
     * 清空购物车
     * @param currentId
     */
    @Delete("DELETE FROM shopping_cart where user_id=#{currentId}")
    void deleteAll(Long currentId);
}
